/**
 * 类装饰器也可以返回一个新的构造函数替换原有的构造函数
 * extends关键字可以代表三种含义：继承、约束、分配
 *
 */

function replaceConstructor<T extends { new (...args: any[]) }>(
  constructor: T
) {
  return class extends constructor {
    constructor(...args) {
      super(...args);
    }
  };
}

class User {
  constructor(public name: string) {
    console.log("User created");
  }
}

const user = new User("Alice");
console.log(user.name);
